package face.yuque;

/**
 * @author spf
 * @date 2024/12/11
 * @time 16:03
 */

//x的平方根
//暴力求解
public class SqrtX1 {
    public static void main(String[] args) {
        System.out.println(sqrtX(24));
    }

    private static int sqrtX(int x) {
        int index = -1;
        for (int i = 0; i < x; i++) {
            if(i*i<=x && (i+1)*(i+1)>x){
                index = i;
            }
        }
        return index;
    }
}
